<link rel="stylesheet" href="components/com_order_branch/assets/jquery-ui.css"/>
<script language="javascript" src="components/com_order_branch/assets/jquery-1.8.2.js"></script>
<script language="javascript" src="components/com_order_branch/assets/jquery-ui.js"></script>
<script>
    $(function() {
        $( "#datepicker" ).datepicker();
    });

</script>
<?php 
	jimport('joomla.application.component.view');
	//thuc hien goi  model phu hop
	class order_branchViewchuyen_hang extends JView
	{
		function display($tpl=null)
		{ 
		    if(isset($_REQUEST['id_kho'])){
            $_SESSION['id_kho'] = $_REQUEST['id_kho'];}
			$model = $this->getModel();
            if(isset($_POST['datepicker']))
            {
                $date = $_POST['datepicker'];
            }
            else
            {
                $date = null;
            }?>
                <h1>Sử lược nhận đơn hàng</h1> 
                <form method="post" action="index.php?option=com_order_branch&task=chuyen_hang"><p>Date:
                <input type="text" id="datepicker" name="datepicker" value="<?php echo $date;?>"/>
                <input type="submit" value="Gửi" /></p></form>
            <?php
            $data = $model->su_luoc_nhan_don_hang($date);
            $i=1;
            //print_r($data);
            ?>
            <table border= "1">
                            <tr>
                                <td>
                                    STT
                                </td>
                                
                                <td>
                                    Sản phẩm
                                </td>
                                
                                        <td>Trạng thái</td>
                                        
                                   
                            </tr>
            <?php 
            foreach($data as $row)
            {
                ?>
                    <tr><form action="index.php?option=com_order_branch&task=van_chuyen" method="post">
                                <td>
                                <input type="hidden" name="date" value="<?php echo $date;?>" />
                                <input name="bill<?php echo $row->id;?>" type="hidden" value="<?php echo $row->id;?>" />
                                    <?php echo $i++;?>
                                </td>
                                <td>
                                    <?php 
                                        $data2 = $model->ds_sp_bill($row->id);
                                        //print_r($data2);
                                        ?>
                                            <table border="1">
                                                <tr>
                                                    <td>Tên sản phẩm</td>
                                                    <td>Số lượng</td>
                                                    <td>Chọn Consig</td>
                                                </tr>
                                            
                                        <?php
                                        foreach($data2 as $row2)
                                        {
                                            ?>
                                                <tr>
                                                    <td>
                                                        <?php echo $row2->name_pro;?>
                                                    </td>
                                                    <td>
                                                        <?php echo $row2->number;?>
                                                        <input type="hidden" name="num_tru<?php echo $row2->id_pro;?>" value="<?php echo $row2->number;?>" />
                                                    </td>
                                                    <td>
                                                        <select name="<?php echo "consig".$row2->id_pro;?>">
                                                            <option value="0">Chọn Consig</option>
                                                            <?php 
                                                                $data3 = $model->lay_consig_theo_id_pro($row2->id_pro);
                                                                foreach($data3 as $row3)
                                                                {
                                                                    ?>
                                                                <option value="<?php echo $row3->consignment_code;?>"><?php echo $row3->consignment_code;
                                                                
                                                                                                                            echo "(".$row3->number_of.")";?></option>    
                                                                    <?php
                                                                }
                                                            ?>
                                                        </select>
                                                    </td>
                                                </tr>
                                            <?php
                                        }?>
                                        </table>
                                        <?php
                                    ?>
                                </td>
                                <td>
                                    <?php if($row->status == 0)
                                        echo "Mới đặt";
                                        else if($row->status == 1)
                                        echo "Đang chuyển";
                                        else echo "Hoàn tất";
                                    ?>
                                </td>
                                <?php 
                                    if($row->status == 0)
                                    {
                                        ?>
                                        <td>
                                            <input type="submit" value="Chuyển" />
                                        </td>
                                        <?php
                                    }
                                ?>
                            </form></tr>
                <?php
            }?></table><?php 
		}	
	}
?>